package com.closer.server.api.admin;

import com.closer.server.biz.organization.dto.CreateRequest;
import com.closer.server.biz.organization.dto.JoinRequest;
import com.closer.server.biz.organization.dto.LeaveRequest;
import com.closer.server.biz.organization.dto.UpdateRequest;
import com.closer.server.support.common.BaseResponse;
import com.closer.server.support.common.ResultUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import com.closer.server.biz.organization.service.OrganizationService;
import org.springframework.web.bind.annotation.RestController;

/**
 * 组织表 控制层。
 *
 * @author closer
 */
@RestController
@RequestMapping("/admin/organization")
public class AdminOrganizationController {

    private final OrganizationService organizationService;

    public AdminOrganizationController(OrganizationService organizationService) {
        this.organizationService = organizationService;
    }

    @PostMapping("/create")
    public BaseResponse<Long> create(@RequestBody CreateRequest params){

        var result = organizationService.create(params);
        return ResultUtils.success(result);
    }

    @PostMapping("/leave")
    public BaseResponse<Boolean> leave(@RequestBody LeaveRequest params){

        var result = organizationService.leave(params);
        return ResultUtils.success(result);
    }

    @PostMapping("/join")
    public BaseResponse<Boolean> join(@RequestBody JoinRequest params){

        var result = organizationService.join(params);
        return ResultUtils.success(result);
    }

    @PostMapping("/update")
    public BaseResponse<Boolean> updateInfo(@RequestBody UpdateRequest params){

        var result = organizationService.updateInfo(params);
        return ResultUtils.success(result);
    }

}
